package com;


import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

// urlPatterns 对哪个请求做过滤
@WebFilter(urlPatterns = "/*")
public class FilterTest implements Filter {


    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    //一个过滤器的核心处理方法
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("过滤器的执行");
        //在过滤器中 处理完成后 要有放行的动作
        filterChain.doFilter(servletRequest,servletResponse);//过滤器放行
    }

    @Override
    public void destroy() {

    }
}
